﻿@*
//------------------------------------------------------------------------------
//  此代码版权声明为全文件覆盖，如有原作者特别声明，会在下方手动补充
//  此代码版权（除特别声明外的代码）归作者本人Diego所有
//  源代码使用协议遵循本仓库的开源协议及附加协议
//  Gitee源代码仓库：https://gitee.com/diego2098/ThingsGateway
//  Github源代码仓库：https://github.com/kimdiego2098/ThingsGateway
//  使用文档：https://diego2098.gitee.io/thingsgateway-docs/
//  QQ群：605534569
//------------------------------------------------------------------------------
*@

@page "/gatewaylog/backendlog"
@using System.Linq.Expressions;
 
@inject UserResoures UserResoures
@namespace ThingsGateway.Gateway.Blazor
@using BlazorComponent;
@using Masa.Blazor
@using Microsoft.AspNetCore.Authorization;

@using ThingsGateway.Admin.Blazor;
@using ThingsGateway.Admin.Core;

@attribute [Authorize]
@inherits BaseComponentBase
@layout MainLayout
<AppDataTable @ref="_datatable" TItem="BackendLog" SearchItem="BackendLogPageInput"
              AddItem="object" EditItem="object" IsShowSelect=false
              SearchModel="@_search" IsShowOperCol=true 
              QueryCallAsync="QueryCallAsync"
                IsShowDetailButton
                IsShowQueryButton>
    <SearchTemplate>

        <MMenu CloseOnContentClick="false" OffsetY Context="menu">
            <ActivatorContent>
                <MTextField Dense Readonly Style="max-width:200px;" HideDetails=@("auto") Class="my-1  mx-2 "
                            Value="context.StartTime.Value.ToDefaultDateTimeFormat(_initTimezone.TimezoneOffset)"
                @attributes="menu.Attrs" Outlined Label=@context.Description(x => x.StartTime) />
            </ActivatorContent>
            <ChildContent>
                <AppDateTimePicker @bind-Value="context.StartTime"></AppDateTimePicker>
            </ChildContent>
        </MMenu>

        <MMenu CloseOnContentClick="false" OffsetY Context="menu">
            <ActivatorContent>
                <MTextField Dense Readonly Style="max-width:200px;" HideDetails=@("auto") Class="my-1  mx-2 "
                            Value="context.EndTime.Value.ToDefaultDateTimeFormat(_initTimezone.TimezoneOffset)" Clearable
                @attributes="menu.Attrs" Outlined Label=@context.Description(x => x.EndTime) />
            </ActivatorContent>
            <ChildContent>
                <AppDateTimePicker @bind-Value="context.EndTime"></AppDateTimePicker>
            </ChildContent>
        </MMenu>


        <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1  mx-2 " @bind-Value="context.Source"
                        Outlined Label=@context.Description(x => x.Source) />
        <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1  mx-2 " @bind-Value="context.Level"
                        Outlined Label=@context.Description(x => x.Level) />

    </SearchTemplate>
    <OtherToolbarTemplate>
        @if (@UserResoures.IsHasButtonWithRole("gatewaybackendlogclear"))
        {
            <MButton Color="error" Class="mx-2 my-1" OnClick=@(ClearClickAsync)>清空</MButton>
        }
        <MMenu OffsetY Context="menu">
            <ActivatorContent>
                <MButton @attributes="@menu.Attrs" Color="primary"
                         Class="my-1  mx-2 ">
                    导出
                    <AppChevronDown></AppChevronDown>
                </MButton>
            </ActivatorContent>
            <ChildContent>
                <MList>
                    <MListItem OnClick="()=>DownExportAsync()"> 导出全部</MListItem>
                    <MListItem OnClick="()=>DownExportAsync(_search)">  导出搜索项 </MListItem>
                </MList>

            </ChildContent>
        </MMenu>

    </OtherToolbarTemplate>
</AppDataTable>



